<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>项目搭建之SpringBoot配置归纳 | 袖清暮雨` Blog</title><meta name="author" content="袖清暮雨"><meta name="copyright" content="袖清暮雨"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="ffffff"><meta name="description" content="父工程(基本配置)1.spring-boot-starter-parent目的12统一管理了 Spring Boot 和相关依赖的版本，确保它们之间的兼容性，避免版本的冲突 具体写法12345&lt;parent&gt;    &lt;artifactId&gt;spring-boot-starter-parent&lt;&#x2F;artifactId&gt;    &lt;groupId&gt;org.">
<meta property="og:type" content="article">
<meta property="og:title" content="项目搭建之SpringBoot配置归纳">
<meta property="og:url" content="https://lemonworld.gitee.io/lemon-world/posts/452204e8.html">
<meta property="og:site_name" content="袖清暮雨&#96; Blog">
<meta property="og:description" content="父工程(基本配置)1.spring-boot-starter-parent目的12统一管理了 Spring Boot 和相关依赖的版本，确保它们之间的兼容性，避免版本的冲突 具体写法12345&lt;parent&gt;    &lt;artifactId&gt;spring-boot-starter-parent&lt;&#x2F;artifactId&gt;    &lt;groupId&gt;org.">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AD%94%E6%B3%95%E5%B0%91%E5%A5%B3%E5%B0%8F%E5%9C%86.png">
<meta property="article:published_time" content="2024-03-17T16:00:00.000Z">
<meta property="article:modified_time" content="2024-04-28T06:48:56.955Z">
<meta property="article:author" content="袖清暮雨">
<meta property="article:tag" content="Java">
<meta property="article:tag" content="传统开发">
<meta property="article:tag" content="SpringBoot">
<meta property="article:tag" content="项目搭建">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AD%94%E6%B3%95%E5%B0%91%E5%A5%B3%E5%B0%8F%E5%9C%86.png"><link rel="shortcut icon" href="/lemon-world/./img/144.png"><link rel="canonical" href="https://lemonworld.gitee.io/lemon-world/posts/452204e8.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//fonts.googleapis.com" crossorigin=""/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="manifest" href="/lemon-world/manifest.json"/><meta name="msapplication-TileColor" content="#3b70fc"/><link rel="apple-touch-icon" sizes="180x180" href="/lemon-world/img/siteicon/128.png"/><link rel="icon" type="image/png" sizes="32x32" href="/lemon-world/img/siteicon/32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/lemon-world/img/siteicon/16.png"/><link rel="mask-icon" href="/lemon-world/img/siteicon/128.png" color="#5bbad5"/><link rel="stylesheet" href="/lemon-world/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web&amp;display=swap" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/lemon-world/',
  algolia: undefined,
  localSearch: {"path":"/lemon-world/search.xml","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '项目搭建之SpringBoot配置归纳',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-04-28 14:48:56'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', 'ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><link rel="stylesheet" href="/css/font.css"><link rel="stylesheet" href="/css/custom.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css"><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu@1.1.6/lib/clock.min.css" /><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-wowjs/lib/animate.min.css" media="print" onload="this.media='screen'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 7.0.0"><link rel="alternate" href="/lemon-world/atom.xml" title="袖清暮雨` Blog" type="application/atom+xml">
</head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/lemon-world/./img/sanjiu.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/lemon-world/archives/"><div class="headline">文章</div><div class="length-num">39</div></a><a href="/lemon-world/tags/"><div class="headline">标签</div><div class="length-num">21</div></a><a href="/lemon-world/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/lemon-world/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa-solid fa-list"></i><span> 学习路线</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/lemon-world/categories/%E5%AD%A6%E4%B9%A0%E4%B8%BB%E7%BA%BF/"><span> 学习主线</span></a></li><li><a class="site-page child" href="/lemon-world/categories/%E5%AD%A6%E4%B9%A0%E6%94%AF%E7%BA%BF/"><span> 学习支线</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/lemon-world/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/comments/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 更多</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/lemon-world/link/"><i class="fa-fw fas fa-link"></i><span> 相关链接</span></a></li><li><a class="site-page child" href="/lemon-world/picture/"><i class="fa-fw fa fa-camera-retro"></i><span> 相册</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AD%94%E6%B3%95%E5%B0%91%E5%A5%B3%E5%B0%8F%E5%9C%86.png')"><nav id="nav"><span id="blog-info"><a href="/lemon-world/" title="袖清暮雨` Blog"><span class="site-name">袖清暮雨` Blog</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/lemon-world/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa-solid fa-list"></i><span> 学习路线</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/lemon-world/categories/%E5%AD%A6%E4%B9%A0%E4%B8%BB%E7%BA%BF/"><span> 学习主线</span></a></li><li><a class="site-page child" href="/lemon-world/categories/%E5%AD%A6%E4%B9%A0%E6%94%AF%E7%BA%BF/"><span> 学习支线</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/lemon-world/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/comments/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 更多</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/lemon-world/link/"><i class="fa-fw fas fa-link"></i><span> 相关链接</span></a></li><li><a class="site-page child" href="/lemon-world/picture/"><i class="fa-fw fa fa-camera-retro"></i><span> 相册</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">项目搭建之SpringBoot配置归纳</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-03-17T16:00:00.000Z" title="发表于 2024-03-18 00:00:00">2024-03-18</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-04-28T06:48:56.955Z" title="更新于 2024-04-28 14:48:56">2024-04-28</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/lemon-world/categories/%E5%AD%A6%E4%B9%A0%E4%B8%BB%E7%BA%BF/">学习主线</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="leancloud_visitors" id="/lemon-world/posts/452204e8.html" data-flag-title="项目搭建之SpringBoot配置归纳"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span class="leancloud-visitors-count"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="父工程-基本配置"><a href="#父工程-基本配置" class="headerlink" title="父工程(基本配置)"></a>父工程(基本配置)</h1><h2 id="1-spring-boot-starter-parent"><a href="#1-spring-boot-starter-parent" class="headerlink" title="1.spring-boot-starter-parent"></a>1.spring-boot-starter-parent</h2><h3 id="目的"><a href="#目的" class="headerlink" title="目的"></a>目的</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">统一管理了 Spring Boot 和相关依赖的版本，</span><br><span class="line">确保它们之间的兼容性，避免版本的冲突</span><br></pre></td></tr></table></figure>
<h3 id="具体写法"><a href="#具体写法" class="headerlink" title="具体写法"></a>具体写法</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;parent&gt;</span><br><span class="line">    &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;</span><br><span class="line">    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</span><br><span class="line">    &lt;version&gt;2.7.14&lt;/version&gt;</span><br><span class="line">&lt;/parent&gt;</span><br></pre></td></tr></table></figure>
<h2 id="2-起步依赖"><a href="#2-起步依赖" class="headerlink" title="2.起步依赖"></a>2.起步依赖</h2><h3 id="目的-1"><a href="#目的-1" class="headerlink" title="目的"></a>目的</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">简化项目开发中的依赖管理，便于管理。</span><br><span class="line">构建 Spring Boot 应用程序时，不再需要手动添加大量的依赖项或者繁琐地配置版本号。</span><br></pre></td></tr></table></figure>
<h3 id="具体讲解"><a href="#具体讲解" class="headerlink" title="具体讲解"></a>具体讲解</h3><p>在spring-boot-starter-parent中的spring-boot-dependencies中，具有大量的其他第三方软件的依赖，已经帮我们规定了版本。从而在我们父工程中直接继承了这些jar包和插件版本。因此，在我们使用时，无需书写依赖的版本号。</p>
<h3 id="具体写法-1"><a href="#具体写法-1" class="headerlink" title="具体写法"></a>具体写法</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">&lt;properties&gt;</span><br><span class="line">        &lt;maven.compiler.source&gt;8&lt;/maven.compiler.source&gt;</span><br><span class="line">        &lt;maven.compiler.target&gt;8&lt;/maven.compiler.target&gt;</span><br><span class="line">        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;</span><br><span class="line">        &lt;!--非springboot依赖版本管理--&gt;</span><br><span class="line">        &lt;mysql.version&gt;8.0.31&lt;/mysql.version&gt;</span><br><span class="line">        ...</span><br><span class="line">&lt;/properties&gt;</span><br><span class="line"></span><br><span class="line">&lt;dependencyManagement&gt;</span><br><span class="line">    &lt;dependencies&gt;</span><br><span class="line">    	&lt;!-- mysql8 驱动包 --&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;mysql&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;mysql.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        ...</span><br><span class="line">    &lt;/dependencies&gt;</span><br><span class="line">&lt;/dependencyManagement&gt;</span><br></pre></td></tr></table></figure>
<h2 id="3-模块管理"><a href="#3-模块管理" class="headerlink" title="3.模块管理"></a>3.模块管理</h2><h3 id="具体写法-2"><a href="#具体写法-2" class="headerlink" title="具体写法"></a>具体写法</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&lt;modules&gt;</span><br><span class="line">    &lt;module&gt;employee&lt;/module&gt;</span><br><span class="line">    &lt;module&gt;towercrane&lt;/module&gt;</span><br><span class="line">    &lt;module&gt;tclive&lt;/module&gt;</span><br><span class="line">    &lt;module&gt;analysis&lt;/module&gt;</span><br><span class="line">    &lt;module&gt;user&lt;/module&gt;</span><br><span class="line">    &lt;module&gt;common&lt;/module&gt;</span><br><span class="line">&lt;/modules&gt;</span><br></pre></td></tr></table></figure>
<h2 id="4-打包的方式"><a href="#4-打包的方式" class="headerlink" title="4.打包的方式"></a>4.打包的方式</h2><h3 id="具体写法-3"><a href="#具体写法-3" class="headerlink" title="具体写法"></a>具体写法</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;packaging&gt;pom&lt;/packaging&gt;</span><br></pre></td></tr></table></figure>
<h1 id="子工程（基本配置）"><a href="#子工程（基本配置）" class="headerlink" title="子工程（基本配置）"></a>子工程（基本配置）</h1><h2 id="知识一：基本操作"><a href="#知识一：基本操作" class="headerlink" title="知识一：基本操作"></a>知识一：基本操作</h2><p><strong>1、</strong>删除父工程中的src</p>
<p><strong>2、</strong>创建module，依旧选择maven，不勾选任何模版 -&gt; 修改模块的名字</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/module%E6%90%AD%E5%BB%BA.png" alt="module搭建1"></p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/module%E6%90%AD%E5%BB%BA2.png" alt="module搭建2"></p>
<p><strong>3、</strong>内部配置</p>
<p><strong>3.1、打包方式</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;packaging&gt;jar&lt;/packaging&gt;</span><br></pre></td></tr></table></figure>
<p><strong>3.2、打包插件</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">&lt;build&gt;</span><br><span class="line">    &lt;plugins&gt;</span><br><span class="line">        &lt;plugin&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;</span><br><span class="line">            &lt;configuration&gt;</span><br><span class="line">                &lt;excludes&gt;</span><br><span class="line">                    &lt;exclude&gt;</span><br><span class="line">                        &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;</span><br><span class="line">                        &lt;artifactId&gt;lombok&lt;/artifactId&gt;</span><br><span class="line">                    &lt;/exclude&gt;</span><br><span class="line">                &lt;/excludes&gt;</span><br><span class="line">            &lt;/configuration&gt;</span><br><span class="line">        &lt;/plugin&gt;</span><br><span class="line">    &lt;/plugins&gt;</span><br><span class="line">&lt;/build&gt;</span><br></pre></td></tr></table></figure>
<p><strong>3.3、删除properties项</strong></p>
<p><strong>3.4、相关依赖添加</strong></p>
<pre><code>&lt;dependencies&gt;
        &lt;!--开发Web应用程序的Spring Boot依赖项--&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
        &lt;/dependency&gt;

        &lt;!--注解所需的导包--&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
            &lt;artifactId&gt;lombok&lt;/artifactId&gt;
            &lt;optional&gt;true&lt;/optional&gt;
        &lt;/dependency&gt;
        ...
&lt;/dependencies&gt;
</code></pre><p><strong>3.4.1说明</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">1、spring-boot-starter-web包含了spring-boot-starter，无需再打spring-boot-starter的依赖进来。</span><br><span class="line">2、@Service注解的依赖包为Spring Framework，由父项目spring-boot-starter-parent自动引入。</span><br><span class="line">3、在父工程中将依赖导入，在子工程中只需通过&lt;dependency&gt;导入对应的内容即可。</span><br><span class="line">	如：</span><br><span class="line">		&lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;mysql&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<p><strong>4、</strong>目录完善</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/module%E7%9A%84%E7%9B%AE%E5%BD%95%E5%AE%8C%E5%96%84.png" alt="module目录完善"></p>
<h2 id="知识二：补充内容：内嵌Web容器-默认Tomcat"><a href="#知识二：补充内容：内嵌Web容器-默认Tomcat" class="headerlink" title="知识二：补充内容：内嵌Web容器(默认Tomcat)"></a>知识二：补充内容：内嵌Web容器(默认Tomcat)</h2><h3 id="具有3个类型的内嵌Web容器"><a href="#具有3个类型的内嵌Web容器" class="headerlink" title="具有3个类型的内嵌Web容器"></a>具有3个类型的内嵌Web容器</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">tomcat(默认)：应用广，负载若干较重的组件</span><br><span class="line">jetty：轻量级，负载性能不及tomcat</span><br><span class="line">undertow：负载性能勉强与tomcat相同</span><br></pre></td></tr></table></figure>
<h3 id="tomcat讲解"><a href="#tomcat讲解" class="headerlink" title="tomcat讲解"></a>tomcat讲解</h3><p>在spring-boot-starter-web依赖中具有spring-boot-starter-tomcat依赖，已经帮我们设置好了，默认使用tomcat服务器</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/tomcat.png" alt=""></p>
<p><strong>解释</strong>：将tomcat执行流程转化为对象，将这个对象交给spring管理，因此相当于在我们springboot中内嵌了一个服务器。</p>
<h3 id="更换内嵌Web容器"><a href="#更换内嵌Web容器" class="headerlink" title="更换内嵌Web容器"></a>更换内嵌Web容器</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;</span><br><span class="line">    &lt;!--排除tomcat起步依赖--&gt;</span><br><span class="line">    &lt;exclusions&gt;</span><br><span class="line">        &lt;exclusion&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;</span><br><span class="line">        &lt;/exclusion&gt;</span><br><span class="line">    &lt;/exclusions&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br><span class="line"></span><br><span class="line">&lt;!--新添jetty内置服务器--&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;spring-boot-starter-jetty&lt;/artifactId&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h1 id="必备配置"><a href="#必备配置" class="headerlink" title="必备配置"></a>必备配置</h1><h2 id="整合lombok"><a href="#整合lombok" class="headerlink" title="整合lombok"></a>整合lombok</h2><h3 id="何为lombok？"><a href="#何为lombok？" class="headerlink" title="何为lombok？"></a>何为lombok？</h3><p> Lombok是一个Java库,能【自动插入编辑器并构建工具】,简化Java开发。主要【常用的注解】有：@Data，@Getter，@Setter，@NoArgsConstructor，@AllArgsConstructor，@ToString，@EqualsAndHashCode，@Slf4j，@Log4j</p>
<h3 id="具体讲解-1"><a href="#具体讲解-1" class="headerlink" title="具体讲解"></a>具体讲解</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">1、entity层：</span><br><span class="line">@Data注解：在JavaBean中使用，这个注解包含范围最广，它包含getter、setter、toString、equals、hashCode方法，即当使用当前注解时，会自动生成@Data包含的所有方法；</span><br><span class="line">@NoArgsConstructor注解：在JavaBean中使用，使用此注解会生成对应的无参构造方法；</span><br><span class="line">@AllArgsConstructor注解：在JavaBean中使用，使用此注解会生成对应的有参构造方法；</span><br><span class="line">@ToString注解：在JavaBean中使用，使用此注解会自动重写对应的toStirng方法；</span><br><span class="line">@EqualsAndHashCode注解：在JavaBean中使用，使用此注解会自动重写对应的equals方法和hashCode方法；</span><br><span class="line"></span><br><span class="line">2、service层：</span><br><span class="line">@Slf4j：在需要打印日志的类中使用，当项目中使用了slf4j打印日志框架时使用该注解，会简化日志的打印流程，只需调用info方法即可；</span><br></pre></td></tr></table></figure>
<h2 id="lombok配置（子工程）"><a href="#lombok配置（子工程）" class="headerlink" title="lombok配置（子工程）"></a>lombok配置（子工程）</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;!--注解所需的导包--&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;lombok&lt;/artifactId&gt;</span><br><span class="line">    &lt;optional&gt;true&lt;/optional&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h1 id="后端-lt-gt-数据库"><a href="#后端-lt-gt-数据库" class="headerlink" title="后端&lt;===&gt;数据库"></a>后端&lt;===&gt;数据库</h1><h2 id="1、-lt-整合Mysql-gt"><a href="#1、-lt-整合Mysql-gt" class="headerlink" title="1、&lt;整合Mysql&gt;"></a>1、&lt;整合Mysql&gt;</h2><h3 id="Mysql配置（虚拟机）"><a href="#Mysql配置（虚拟机）" class="headerlink" title="Mysql配置（虚拟机）"></a>Mysql配置（虚拟机）</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;!--mysql驱动包：连接虚拟机--&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;com.mysql&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;mysql-connector-j&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;8.0.33&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h3 id="Mysql配置（windows）"><a href="#Mysql配置（windows）" class="headerlink" title="Mysql配置（windows）"></a>Mysql配置（windows）</h3><h4 id="1-版本号"><a href="#1-版本号" class="headerlink" title="1.版本号"></a>1.版本号</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;mysql.version&gt;8.0.31&lt;/mysql.version&gt;</span><br></pre></td></tr></table></figure>
<h4 id="2-依赖"><a href="#2-依赖" class="headerlink" title="2.依赖"></a>2.依赖</h4><h5 id="2-1父工程"><a href="#2-1父工程" class="headerlink" title="2.1父工程"></a>2.1父工程</h5><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- mysql8 驱动包 --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;mysql&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;$&#123;mysql.version&#125;&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h5 id="2-2子工程"><a href="#2-2子工程" class="headerlink" title="2.2子工程"></a>2.2子工程</h5><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- mysql8 驱动包 --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;mysql&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h4 id="3-yml配置"><a href="#3-yml配置" class="headerlink" title="3.yml配置"></a>3.yml配置</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">spring:</span><br><span class="line">  datasource:</span><br><span class="line">    driver-class-name: com.mysql.cj.jdbc.Driver</span><br><span class="line">    url: jdbc:mysql://localhost:3306/zhou?useSSL=true&amp;useUnicode=true&amp;characterEncoding=utf-8</span><br><span class="line">    username: root</span><br><span class="line">    password: zhou13306250032</span><br></pre></td></tr></table></figure>
<h5 id="解释"><a href="#解释" class="headerlink" title="解释"></a>解释</h5><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">spring:</span><br><span class="line">  datasource:</span><br><span class="line">    driverClassName: 固定写法</span><br><span class="line">    url: jdbc:mysql://地址/【数据库名】?配置项1&amp;配置项2</span><br><span class="line">    username: 数据库账户名</span><br><span class="line">    password: 数据库账户密码</span><br></pre></td></tr></table></figure>
<h2 id="2-lt-整合Mybatis-Plus-gt"><a href="#2-lt-整合Mybatis-Plus-gt" class="headerlink" title="2.&lt;整合Mybatis Plus&gt;"></a>2.&lt;整合Mybatis Plus&gt;</h2><h3 id="2-1、何为Mybatis-Plus？"><a href="#2-1、何为Mybatis-Plus？" class="headerlink" title="2.1、何为Mybatis Plus？"></a>2.1、何为Mybatis Plus？</h3><p>MyBatis Plus(简称 MP)是一款 MyBatis 的增强工具。用于【<strong>后端与数据库进行简化交互(连接)</strong>】的一种持久层框架，基于MyBatis，MyBatis内部则封装了jdbc的持久层框架。在 MyBatis 的基础上只做增强不做改变，为简化开发、提高效率而生。</p>
<h3 id="2-2、Mybatis-Plus配置"><a href="#2-2、Mybatis-Plus配置" class="headerlink" title="2.2、Mybatis Plus配置"></a>2.2、Mybatis Plus配置</h3><h4 id="2-2-1版本号"><a href="#2-2-1版本号" class="headerlink" title="2.2.1版本号"></a>2.2.1版本号</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;mybatis.plus.version&gt;3.5.0&lt;/mybatis.plus.version&gt;</span><br></pre></td></tr></table></figure>
<h4 id="2-2-2依赖"><a href="#2-2-2依赖" class="headerlink" title="2.2.2依赖"></a>2.2.2依赖</h4><h5 id="2-2-2-1父工程"><a href="#2-2-2-1父工程" class="headerlink" title="2.2.2.1父工程"></a>2.2.2.1父工程</h5><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- mybatis-plus --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;com.baomidou&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;mybatis-plus-boot-starter&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;$&#123;mybatis.plus.version&#125;&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h5 id="2-2-2-1子工程"><a href="#2-2-2-1子工程" class="headerlink" title="2.2.2.1子工程"></a>2.2.2.1子工程</h5><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- mybatis-plus --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;com.baomidou&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;mybatis-plus-boot-starter&lt;/artifactId&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h4 id="2-2-3yml配置"><a href="#2-2-3yml配置" class="headerlink" title="2.2.3yml配置"></a>2.2.3yml配置</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mybatis-plus:</span><br><span class="line">  type-aliases-package: org.ybg.FirstWeb.business.entity</span><br><span class="line">  mapper-locations: classpath*:mapping/*Mapper.xml</span><br><span class="line">  configuration:</span><br><span class="line">    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl</span><br><span class="line">    map-underscore-to-camel-case: true</span><br><span class="line">    use-column-label: true</span><br></pre></td></tr></table></figure>
<h5 id="解释-1"><a href="#解释-1" class="headerlink" title="解释"></a>解释</h5><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">type-aliases-package =&gt; MyBatis Plus 应该扫描的 Java 实体类的包路径,【相当于&quot;@Mapper&quot;】</span><br><span class="line">mapper-locations =&gt; MyBatis Plus 应该扫描的 XML 映射文件的路径（复杂sql）【固定】</span><br><span class="line">log-impl =&gt; MybatisPlus日志(固定写法：将日志输出到控制台)</span><br><span class="line">map-underscore-to-camel-case =&gt;是否开启下划线命名规则和驼峰命名规则之间的映射</span><br><span class="line">use-column-label =&gt; 是否使用列标签作为结果集映射的属性名</span><br></pre></td></tr></table></figure>
<h3 id="2-3、Mybatis-Plus中的注解-entity层"><a href="#2-3、Mybatis-Plus中的注解-entity层" class="headerlink" title="2.3、Mybatis Plus中的注解(entity层)"></a>2.3、Mybatis Plus中的注解(entity层)</h3><p><strong>具体讲解</strong>：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">类名相关：</span><br><span class="line">@TableName(&quot;tb_user&quot;)			表名与类名不一致	✔</span><br><span class="line"></span><br><span class="line">属性相关：</span><br><span class="line">	表现形态：</span><br><span class="line">		@TableId()	✔</span><br><span class="line">		@TableField()	✔</span><br><span class="line">	具体讲解：</span><br><span class="line">			@TableId(type = IdType.AUTO)	自增列（标识主键）	✔</span><br><span class="line">			value=&quot;NAME&quot;					字段名不一致【若只是存在驼峰差异，开启驼峰后可或缺】	✔</span><br><span class="line">			exist=false						非表字段，默认为true</span><br><span class="line">			select=false					不加入查询，默认为true</span><br><span class="line">			strategy=&#x27;&#x27;					字段验证，默认非空	✔</span><br><span class="line">				insertStrategy=&quot;FieldStrategy.xxx&quot; 	在insert操作时的字段策略，是否进行空值判断，插入空值</span><br><span class="line">				updateStrategy=&quot;FieldStrategy.xxx&quot; 	在update操作时的字段策略，是否进行空值判断，插入空值</span><br><span class="line">				whereStrategy=&quot;FieldStrategy.xxx&quot; 	在where条件组装时，是否进行控制判断，将空值作为查询条件</span><br></pre></td></tr></table></figure>
<h2 id="3-lt-整合Druid-gt"><a href="#3-lt-整合Druid-gt" class="headerlink" title="3.&lt;整合Druid&gt;"></a>3.&lt;整合Druid&gt;</h2><h3 id="3-1、何为Druid？"><a href="#3-1、何为Druid？" class="headerlink" title="3.1、何为Druid？"></a>3.1、何为Druid？</h3><p>Druid 是阿里巴巴开源的一个【<strong>数据库连接池</strong>】实现，用于管理和优化数据库【连接】，以提高性能，稳定性和安全性。</p>
<p>(连接池：程序初始化时，创建多个数据库连接，将其集中管理，供程序使用确保较快的数据读写速度。)</p>
<h3 id="3-2、Druid配置"><a href="#3-2、Druid配置" class="headerlink" title="3.2、Druid配置"></a>3.2、Druid配置</h3><h4 id="3-2-1版本号"><a href="#3-2-1版本号" class="headerlink" title="3.2.1版本号"></a>3.2.1版本号</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;druid.starter.version&gt;1.1.24&lt;/druid.starter.version&gt;</span><br></pre></td></tr></table></figure>
<p><strong>说明</strong>：<strong>druid-spring-boot-starter</strong>【包含】 <strong>Druid</strong> 相关的配置和依赖，无需手动编写配置类并注入到bean中，并加载对应的配置参数。</p>
<h4 id="3-2-2依赖"><a href="#3-2-2依赖" class="headerlink" title="3.2.2依赖"></a>3.2.2依赖</h4><h5 id="3-2-2-1父工程"><a href="#3-2-2-1父工程" class="headerlink" title="3.2.2.1父工程"></a>3.2.2.1父工程</h5><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- alibaba druid数据源 --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;com.alibaba&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;druid-spring-boot-starter&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;$&#123;druid.starter.version&#125;&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h5 id="3-2-2-2子工程"><a href="#3-2-2-2子工程" class="headerlink" title="3.2.2.2子工程"></a>3.2.2.2子工程</h5><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- alibaba druid数据源 --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;com.alibaba&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;druid-spring-boot-starter&lt;/artifactId&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h4 id="3-2-3yml配置-无需mysql的yml配置"><a href="#3-2-3yml配置-无需mysql的yml配置" class="headerlink" title="3.2.3yml配置(无需mysql的yml配置)"></a>3.2.3yml配置(无需mysql的yml配置)</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">spring:</span><br><span class="line">  datasource:</span><br><span class="line">    druid:</span><br><span class="line">      driver-class-name: com.mysql.cj.jdbc.Driver</span><br><span class="line">      url: jdbc:mysql://localhost:3306/zhou?useSSL=true&amp;useUnicode=true&amp;characterEncoding=utf-8</span><br><span class="line">      username: root</span><br><span class="line">      password: zhou13306250032</span><br><span class="line">      min-idle: 3</span><br><span class="line">      max-active: 8</span><br><span class="line">      max-wait: 10000</span><br><span class="line">      test-on-borrow: true</span><br><span class="line">      validation-query: select 1=1</span><br></pre></td></tr></table></figure>
<h3 id="3-3、Druid数据源配置"><a href="#3-3、Druid数据源配置" class="headerlink" title="3.3、Druid数据源配置"></a>3.3、Druid数据源配置</h3><pre><code># 初始连接数
initial-size: 5

# 最小连接池数量
min-idle: 10

# 最大连接池数量
max-active: 20

# 配置获取连接等待超时的时间
max-wait: 60000

# 配置间隔多久才进行一次检测，检测需要关闭的空闲连接，单位是毫秒
time-between-eviction-runs-millis: 60000

# 配置一个连接在池中最小生存的时间，单位是毫秒
min-evictable-idle-time-millis: 300000

# 配置检测连接是否有效
validation-query: select 1=1

# 配置一个连接在池中最大生存的时间，单位是毫秒
maxEvictableIdleTimeMillis: 900000

#申请连接的时候检测，如果空闲时间大于time-between-eviction-runs-millis，执行validation-query检测连接是否有效。
test-while-idle: true

#配置从连接池获取连接时，是否检查连接有效性，true每次都检查；false不检查。做了这个配置会降低性能。
test-on-borrow: false

#配置向连接池归还连接时，是否检查连接有效性，true每次都检查；false不检查。做了这个配置会降低性能。
test-on-return: false

#用于指定是否缓存预编译的 SQL 语句
pool-prepared-statements: true
#每个数据库连接上可以缓存的预编译SQL语句的最大数量。若已有缓存的预编译SQL语句且未达最大值，Druid 数据源将直接从缓存中获取并使用，而不需要重新创建，从而提高数据库操作的性能
max-pool-prepared-statement-per-connection-size: 20

#过滤器：stat是收集连接池的统计信息，实时监控连接池的运行情况，以便及时发现并解决潜在的性能问题; wall是SQL 防火墙过滤器，用于防止 SQL 注入攻击; log4j是将 Druid 数据源的日志信息整合到项目的日志系统中，方便统一管理和查看
filters: stat,wall,log4j

#合并多个DruidDatasource的监控数据
use-global-data-source-stat: true

#druid.stat.mergeSql：合并相同的 SQL 语句并统计执行次数，减少重复记录
#druid.stat.slowSqlMillis：超过这个值，就会记录到慢SQL记录
connect-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500;
</code></pre><h2 id="4-整合Redis-—在虚拟机当中"><a href="#4-整合Redis-—在虚拟机当中" class="headerlink" title="4.((整合Redis))—在虚拟机当中"></a>4.((整合Redis))—在虚拟机当中</h2><h3 id="4-1、何为Redis？"><a href="#4-1、何为Redis？" class="headerlink" title="4.1、何为Redis？"></a>4.1、何为Redis？</h3><p>Redis是【基于内存的数据库】，其特点便是【快】。</p>
<h3 id="4-2、Redis配置"><a href="#4-2、Redis配置" class="headerlink" title="4.2、Redis配置"></a>4.2、Redis配置</h3><h4 id="版本号"><a href="#版本号" class="headerlink" title="版本号"></a>版本号</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;jedis.version&gt;3.8.0&lt;/jedis.version&gt;</span><br></pre></td></tr></table></figure>
<h4 id="依赖"><a href="#依赖" class="headerlink" title="依赖"></a>依赖</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- jedis : java to redis --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;redis.clients&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;jedis&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;$&#123;jedis.version&#125;&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h4 id="yml配置"><a href="#yml配置" class="headerlink" title="yml配置"></a>yml配置</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">spring:</span><br><span class="line">  redis:</span><br><span class="line">    expiration: 5</span><br><span class="line">    time-unit: m</span><br><span class="line">    database: 0</span><br><span class="line">    host: 192.168.229.130</span><br><span class="line">    port: 6379</span><br><span class="line">    password: zhou13306250032</span><br><span class="line">    jedis:</span><br><span class="line">      pool:</span><br><span class="line">        min-idle: 3</span><br><span class="line">        max-idle: 5</span><br><span class="line">        max-active: 8</span><br><span class="line">        max-wait: 10</span><br></pre></td></tr></table></figure>
<h5 id="讲解"><a href="#讲解" class="headerlink" title="讲解"></a>讲解</h5><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">spring:</span><br><span class="line">  redis:</span><br><span class="line">    expiration: 定义 Redis 中存储的数据的默认过期时间</span><br><span class="line">    time-unit: 定义过期时间的单位</span><br><span class="line">    database: redis数据库索引(默认为0)</span><br><span class="line">    host: redis服务器地址（默认为loaclhost）</span><br><span class="line">    port: redis端口（默认为6379）</span><br><span class="line">    password: 密码</span><br><span class="line">    # redis连接池配置</span><br><span class="line">    jedis:</span><br><span class="line">      pool:</span><br><span class="line">      	# 最小空闲连接数（默认为0，该值只有为正数才有用）</span><br><span class="line">        min-idle: 3</span><br><span class="line">        # 最大空闲连接数（默认为8，负数表示无限）</span><br><span class="line">        max-idle: 5</span><br><span class="line">        # 最大可用连接数（默认为8，负数表示无限）</span><br><span class="line">        max-active: 8</span><br><span class="line">        # 从连接池中获取连接最大等待时间（默认为-1，单位为毫秒，负数表示无限）</span><br><span class="line">        max-wait: 10</span><br></pre></td></tr></table></figure>
<p>5.整合</p>
<h1 id="前端-lt-gt-后端"><a href="#前端-lt-gt-后端" class="headerlink" title="前端&lt;===&gt;后端"></a>前端&lt;===&gt;后端</h1><h2 id="1-整合validation"><a href="#1-整合validation" class="headerlink" title="1.整合validation"></a>1.整合validation</h2><h3 id="1-1、何为validation？"><a href="#1-1、何为validation？" class="headerlink" title="1.1、何为validation？"></a>1.1、何为validation？</h3><p>validation主要用于前端传到后端的<strong>数据校验</strong>（长度）。常用于【注册】与【登入】页面处。</p>
<h3 id="1-2、validation配置"><a href="#1-2、validation配置" class="headerlink" title="1.2、validation配置"></a>1.2、validation配置</h3><h4 id="1-2-1：依赖"><a href="#1-2-1：依赖" class="headerlink" title="1.2.1：依赖"></a>1.2.1：依赖</h4><p><strong>子工程</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- validation：数据校验 --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;spring-boot-starter-validation&lt;/artifactId&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h4 id="1-2-2：使用方式"><a href="#1-2-2：使用方式" class="headerlink" title="1.2.2：使用方式"></a>1.2.2：使用方式</h4><p><strong>一</strong>：参数为【<strong>非对象格式</strong>】，需在controller类上面添加@Validated注解。</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/validation%E9%9D%9E%E5%AF%B9%E8%B1%A1.png" alt=""></p>
<p><strong>二</strong>：参数为【<strong>对象</strong>】，在属性前面添加@Valid注解</p>
<p><strong>entity内部注解</strong></p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/validation%E5%AF%B9%E8%B1%A112.0.png" alt=""></p>
<p><strong>controller内注解</strong></p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/validation%E5%AF%B9%E8%B1%A122.0.png" alt=""></p>
<p><strong>三</strong>：自定义校验</p>
<p> 自定义注解State</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">import com.backsystem.common.validation.StateValidation;</span><br><span class="line">import javax.validation.Constraint;</span><br><span class="line">import javax.validation.Payload;</span><br><span class="line">import java.lang.annotation.*;</span><br><span class="line">import static java.lang.annotation.ElementType.FIELD;</span><br><span class="line">import static java.lang.annotation.RetentionPolicy.RUNTIME;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 1.自定义注解State</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">@Documented //元注解</span><br><span class="line">@Constraint(</span><br><span class="line">        validatedBy = &#123;StateValidation.class&#125; //指定提供校验规则的类【自定义】</span><br><span class="line">)</span><br><span class="line">@Target(&#123;FIELD&#125;) //元注解：作用于xxx上</span><br><span class="line">@Retention(RUNTIME)//元注解：在何时保留：运行时阶段保留</span><br><span class="line">public @interface State &#123;</span><br><span class="line">    //提供校验失败时的提示信息</span><br><span class="line">    String message() default &quot;state参数的值只能是已发布或者草稿&quot;;</span><br><span class="line"></span><br><span class="line">    //指定分组</span><br><span class="line">    Class&lt;?&gt;[] groups() default &#123;&#125;;</span><br><span class="line"></span><br><span class="line">    //负载，获取到state注解的附加信息</span><br><span class="line">    Class&lt;? extends Payload&gt;[] payload() default &#123;&#125;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>自定义校验规则的类StateValidation，实现ConstraintValidator接口</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">import com.backsystem.common.annotate.State;</span><br><span class="line">import javax.validation.ConstraintValidator;</span><br><span class="line">import javax.validation.ConstraintValidatorContext;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 2.自定义校验规则的类StateValidation，实现ConstraintValidator接口</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">//ConstraintValidator&lt;给哪个注解提供校验规则,校验的数据类型&gt;</span><br><span class="line">public class StateValidation implements ConstraintValidator&lt;State,String&gt; &#123;</span><br><span class="line">    /**</span><br><span class="line">     *</span><br><span class="line">     * @param value 将来要校验的数据</span><br><span class="line">     * @param constraintValidatorContext</span><br><span class="line">     * @return 如果返回false，则校验【不通过】；如果返回true，则校验【通过】</span><br><span class="line">     */</span><br><span class="line">    @Override</span><br><span class="line">    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) &#123;</span><br><span class="line">        //提供校验规则</span><br><span class="line">        if (value == null)&#123;</span><br><span class="line">            return false;</span><br><span class="line">        &#125;</span><br><span class="line">        if (value.equals(&quot;已发布&quot;) || value.equals(&quot;草稿&quot;))&#123;</span><br><span class="line">            return true;</span><br><span class="line">        &#125;</span><br><span class="line">        return false;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>在需要校验的地方使用自定义注解</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/state%E8%87%AA%E5%AE%9A%E4%B9%89%E6%B3%A8%E8%A7%A3.png" alt=""></p>
<h4 id="1-2-3：validation注解表"><a href="#1-2-3：validation注解表" class="headerlink" title="1.2.3：validation注解表"></a>1.2.3：validation注解表</h4><p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/validation%E6%B3%A8%E8%A7%A3%E8%A1%A8.png" alt=""></p>
<p><strong>注：message字段为不符合校验规则时抛出的异常信息</strong></p>
<h4 id="1-2-4：异常处理器GlobalExceptionHandler"><a href="#1-2-4：异常处理器GlobalExceptionHandler" class="headerlink" title="1.2.4：异常处理器GlobalExceptionHandler"></a>1.2.4：异常处理器GlobalExceptionHandler</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">import org.springframework.util.StringUtils;</span><br><span class="line">import org.springframework.web.bind.annotation.ExceptionHandler;</span><br><span class="line">import org.springframework.web.bind.annotation.RestControllerAdvice;</span><br><span class="line"></span><br><span class="line">//全局异常处理器</span><br><span class="line">@RestControllerAdvice</span><br><span class="line">public class GlobalExceptionHandler &#123;</span><br><span class="line">    //validation：参数校验失败异常</span><br><span class="line">    @ExceptionHandler(ValidationException.class)</span><br><span class="line">    public Result handleException(ValidationException e)&#123;</span><br><span class="line">        e.printStackTrace();</span><br><span class="line">        return Result.error(StringUtils.hasLength(e.getMessage()) ? e.getMessage() : &quot;操作失败&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="2-整合JWT-ThreadLocal"><a href="#2-整合JWT-ThreadLocal" class="headerlink" title="2.整合JWT+ThreadLocal"></a>2.整合JWT+ThreadLocal</h2><h3 id="2-1：何为JWT？"><a href="#2-1：何为JWT？" class="headerlink" title="2.1：何为JWT？"></a>2.1：何为JWT？</h3><p><strong>Token主要用于身份验证和授权的凭据，通常是一个字符串。通常使用JWT进行表示</strong>。【JWT全称JSON Web Token，以json格式进行数据的传输。】</p>
<p>其中<strong>JWT主要作用于登入认证的功能</strong>。JWT相当于令牌，当浏览器从登录页面得到令牌后，才可以访问其他的页面，否则无法访问。</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E7%99%BB%E5%BD%95%E8%AE%A4%E8%AF%813.0.png" alt=""></p>
<h3 id="2-2：JWT组成部分讲解"><a href="#2-2：JWT组成部分讲解" class="headerlink" title="2.2：JWT组成部分讲解"></a>2.2：JWT组成部分讲解</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">第一部分：Header（头）</span><br><span class="line">第二部分：Payload（有效载荷）：不可携带敏感信息,如：密码...</span><br><span class="line">第三部分：Signature（签名）</span><br></pre></td></tr></table></figure>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/JWT%E7%BB%84%E6%88%90.png" alt=""></p>
<h3 id="2-3：ThreadLocal的讲解"><a href="#2-3：ThreadLocal的讲解" class="headerlink" title="2.3：ThreadLocal的讲解"></a>2.3：ThreadLocal的讲解</h3><p><strong>定义</strong>：ThreadLocal用于多线程环境下存储线程局部变量。它允许每个线程都有自己独立的变量副本，而不会相互影响。</p>
<p><strong>理解</strong>：去银行排队办理业务，每个人都有自己的服务号码，服务号码只在本人办理业务时有效，不会影响其他人。这就好比 ThreadLocal 给每个线程分配了一个“服务号码”，线程在执行时可以独立使用这个“号码”来存储自己的数据，而不会和其他线程的数据产生冲突。</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/threadlocal.png" alt=""></p>
<p><strong>特点</strong>：</p>
<ol>
<li><strong>线程隔离：</strong> 每个线程都拥有自己独立的 ThreadLocal 实例，线程之间互不干扰，可以存储各自的数据。</li>
<li><strong>线程内共享：</strong> 在同一个线程内，多个方法之间可以共享同一个 ThreadLocal 实例中的数据，方便数据在方法之间传递。</li>
<li><strong>避免线程安全问题：</strong> 使用 ThreadLocal 可以避免多线程环境下的数据共享和竞态条件，因为每个线程都拥有自己独立的数据副本。</li>
</ol>
<h3 id="2-4：JWT-ThreadLocal配置"><a href="#2-4：JWT-ThreadLocal配置" class="headerlink" title="2.4：JWT+ThreadLocal配置"></a>2.4：JWT+ThreadLocal配置</h3><h4 id="版本号-1"><a href="#版本号-1" class="headerlink" title="版本号"></a>版本号</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;jwt.version&gt;4.4.0&lt;/jwt.version&gt;</span><br></pre></td></tr></table></figure>
<h4 id="依赖-1"><a href="#依赖-1" class="headerlink" title="依赖"></a>依赖</h4><p><strong>父工程</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- JWT --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;com.auth0&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;java-jwt&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;$&#123;jwt.version&#125;&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<p><strong>子工程</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- jwt令牌 --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;com.auth0&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;java-jwt&lt;/artifactId&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h4 id="具体配置项"><a href="#具体配置项" class="headerlink" title="具体配置项"></a>具体配置项</h4><p><strong>登录拦截器</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">import com.backsystem.Utils.JwtUtil;</span><br><span class="line">import com.backsystem.Utils.ThreadLocalUtil;</span><br><span class="line">import org.springframework.stereotype.Component;</span><br><span class="line">import org.springframework.web.servlet.HandlerInterceptor;</span><br><span class="line"></span><br><span class="line">import javax.servlet.http.HttpServletRequest;</span><br><span class="line">import javax.servlet.http.HttpServletResponse;</span><br><span class="line">import java.util.Map;</span><br><span class="line"></span><br><span class="line">//登入拦截器：传递token</span><br><span class="line">@Component</span><br><span class="line">public class LoginInterceptor implements HandlerInterceptor &#123;</span><br><span class="line">    @Override</span><br><span class="line">    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception &#123;</span><br><span class="line">        //令牌验证</span><br><span class="line">        String token = request.getHeader(&quot;Authorization&quot;);//获取令牌</span><br><span class="line">        try&#123;</span><br><span class="line">            //解析token,获取数据</span><br><span class="line">            Map&lt;String,Object&gt; claims = JwtUtil.parseToken(token);</span><br><span class="line">            //将数据存储于ThreadLocal中</span><br><span class="line">            ThreadLocalUtil.set(claims);</span><br><span class="line">            //放行</span><br><span class="line">            return true;</span><br><span class="line">        &#125;catch (Exception e)&#123;</span><br><span class="line">            //http为401错误</span><br><span class="line">            response.setStatus(401);</span><br><span class="line">            //不放行</span><br><span class="line">            return false;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Override</span><br><span class="line">    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception &#123;</span><br><span class="line">        //清空ThreadLocal中数据</span><br><span class="line">        ThreadLocalUtil.remove();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>注入拦截器</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">import com.backsystem.config.interceptor.LoginInterceptor;</span><br><span class="line">import org.springframework.beans.factory.annotation.Autowired;</span><br><span class="line">import org.springframework.context.annotation.Configuration;</span><br><span class="line">import org.springframework.web.servlet.config.annotation.InterceptorRegistry;</span><br><span class="line">import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;</span><br><span class="line"></span><br><span class="line">@Configuration</span><br><span class="line">public class WebConfig implements WebMvcConfigurer &#123;</span><br><span class="line"></span><br><span class="line">    @Autowired</span><br><span class="line">    private LoginInterceptor loginInterceptor;</span><br><span class="line">    //注入拦截器</span><br><span class="line">    @Override</span><br><span class="line">    public void addInterceptors(InterceptorRegistry registry) &#123;</span><br><span class="line">        //登录接口与注册接口不拦截</span><br><span class="line">        registry.addInterceptor(loginInterceptor)</span><br><span class="line">                .excludePathPatterns(&quot;/user/login&quot;,&quot;/user/register&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="3-整合PageHelper"><a href="#3-整合PageHelper" class="headerlink" title="3.整合PageHelper"></a>3.整合PageHelper</h2><h3 id="3-1：何为PageHelper？"><a href="#3-1：何为PageHelper？" class="headerlink" title="3.1：何为PageHelper？"></a>3.1：何为PageHelper？</h3><p>PageHelper 是 MyBatis 的一个【<strong>分页插件</strong>】，它能够帮助开发者在进行数据库查询时实现分页功能。</p>
<h3 id="3-2：PageHelper配置"><a href="#3-2：PageHelper配置" class="headerlink" title="3.2：PageHelper配置"></a>3.2：PageHelper配置</h3><h4 id="版本号-2"><a href="#版本号-2" class="headerlink" title="版本号"></a>版本号</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;pagehelper.version&gt;1.4.6&lt;/pagehelper.version&gt;</span><br></pre></td></tr></table></figure>
<h4 id="依赖-2"><a href="#依赖-2" class="headerlink" title="依赖"></a>依赖</h4><p><strong>父类</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- PageHelper --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;com.github.pagehelper&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;pagehelper-spring-boot-starter&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;1.4.7&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<p><strong>子类</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- PageHelper --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;com.github.pagehelper&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;pagehelper-spring-boot-starter&lt;/artifactId&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<h2 id="4-整合hutool-all（文件上传下载中需用到）"><a href="#4-整合hutool-all（文件上传下载中需用到）" class="headerlink" title="4.整合hutool-all（文件上传下载中需用到）"></a>4.整合hutool-all（文件上传下载中需用到）</h2><h3 id="4-1、何为hutool-all？"><a href="#4-1、何为hutool-all？" class="headerlink" title="4.1、何为hutool-all？"></a>4.1、何为hutool-all？</h3><p>Hutool是一个小而全的Java工具类库。<strong>在文件上传下载中需要用到</strong>。</p>
<h3 id="4-2、hutool-all配置"><a href="#4-2、hutool-all配置" class="headerlink" title="4.2、hutool-all配置"></a>4.2、hutool-all配置</h3><h4 id="版本号-3"><a href="#版本号-3" class="headerlink" title="版本号"></a>版本号</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;hutoolall.version&gt;5.8.20&lt;/hutoolall.version&gt;</span><br></pre></td></tr></table></figure>
<h4 id="依赖-3"><a href="#依赖-3" class="headerlink" title="依赖"></a>依赖</h4><p><strong>父工程</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- Hutool-all:小而全的Java工具类库 --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;cn.hutool&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;hutool-all&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;$&#123;hutoolall.version&#125;&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<p><strong>子工程</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;!--hutool-all:小而全的Java工具类库--&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;cn.hutool&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;hutool-all&lt;/artifactId&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://lemonworld.gitee.io/lemon-world">袖清暮雨</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://lemonworld.gitee.io/lemon-world/posts/452204e8.html">https://lemonworld.gitee.io/lemon-world/posts/452204e8.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://lemonworld.gitee.io/lemon-world" target="_blank">袖清暮雨` Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/lemon-world/tags/Java/">Java</a><a class="post-meta__tags" href="/lemon-world/tags/%E4%BC%A0%E7%BB%9F%E5%BC%80%E5%8F%91/">传统开发</a><a class="post-meta__tags" href="/lemon-world/tags/SpringBoot/">SpringBoot</a><a class="post-meta__tags" href="/lemon-world/tags/%E9%A1%B9%E7%9B%AE%E6%90%AD%E5%BB%BA/">项目搭建</a></div><div class="post_share"><div class="social-share" data-image="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AD%94%E6%B3%95%E5%B0%91%E5%A5%B3%E5%B0%8F%E5%9C%86.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/lemon-world/posts/c58b53ae.html" title="RDB优化"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%BB%84%E6%98%8F%E4%B8%8B.png" onerror="onerror=null;src='/lemon-world/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">RDB优化</div></div></a></div><div class="next-post pull-right"><a href="/lemon-world/posts/7f721cb1.html" title="项目搭建之SpringBoot基本操作归纳"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E6%A1%A5%E4%B8%8B%E5%A4%95%E9%98%B3.png" onerror="onerror=null;src='/lemon-world/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">项目搭建之SpringBoot基本操作归纳</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/lemon-world/posts/7f721cb1.html" title="项目搭建之SpringBoot基本操作归纳"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E6%A1%A5%E4%B8%8B%E5%A4%95%E9%98%B3.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-03-27</div><div class="title">项目搭建之SpringBoot基本操作归纳</div></div></a></div><div><a href="/lemon-world/posts/ca437b77.html" title="项目搭建之Vue工程之初步搭建"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AC%BC%E7%81%AD.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-02-24</div><div class="title">项目搭建之Vue工程之初步搭建</div></div></a></div><div><a href="/lemon-world/posts/1e302926.html" title="项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E8%BF%BD%E6%9C%88.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-04-11</div><div class="title">项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战</div></div></a></div><div><a href="/lemon-world/posts/cca50181.html" title="项目搭建之Vue工程之路由"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E5%A4%95%E9%98%B3%E4%B8%8B%E7%9A%84%E7%BA%A2%E8%B7%AF%E7%81%AF.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-04-12</div><div class="title">项目搭建之Vue工程之路由</div></div></a></div><div><a href="/lemon-world/posts/dc99e4b2.html" title="项目搭建之文件上传下载"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%97%B4%E8%B0%8D%E8%BF%87%E5%AE%B6%E5%AE%B6.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-04-20</div><div class="title">项目搭建之文件上传下载</div></div></a></div><div><a href="/lemon-world/posts/54849ec2.html" title="大数据之Hadoop（HDFS Java客户端操作）"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E7%8E%9B%E5%A5%87%E7%8E%9B.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-01-14</div><div class="title">大数据之Hadoop（HDFS Java客户端操作）</div></div></a></div></div></div><hr class="custom-hr"/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="/lemon-world/./img/sanjiu.jpg" onerror="this.onerror=null;this.src='/lemon-world/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">袖清暮雨</div><div class="author-info__description">一个技术宅的博客</div></div><div class="card-info-data site-data is-center"><a href="/lemon-world/archives/"><div class="headline">文章</div><div class="length-num">39</div></a><a href="/lemon-world/tags/"><div class="headline">标签</div><div class="length-num">21</div></a><a href="/lemon-world/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/Lemon-World"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/Lemon-World" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">欢迎来到袖清暮雨`Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%88%B6%E5%B7%A5%E7%A8%8B-%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AE"><span class="toc-number">1.</span> <span class="toc-text">父工程(基本配置)</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-spring-boot-starter-parent"><span class="toc-number">1.1.</span> <span class="toc-text">1.spring-boot-starter-parent</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E7%9A%84"><span class="toc-number">1.1.1.</span> <span class="toc-text">目的</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B7%E4%BD%93%E5%86%99%E6%B3%95"><span class="toc-number">1.1.2.</span> <span class="toc-text">具体写法</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E8%B5%B7%E6%AD%A5%E4%BE%9D%E8%B5%96"><span class="toc-number">1.2.</span> <span class="toc-text">2.起步依赖</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E7%9A%84-1"><span class="toc-number">1.2.1.</span> <span class="toc-text">目的</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B7%E4%BD%93%E8%AE%B2%E8%A7%A3"><span class="toc-number">1.2.2.</span> <span class="toc-text">具体讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B7%E4%BD%93%E5%86%99%E6%B3%95-1"><span class="toc-number">1.2.3.</span> <span class="toc-text">具体写法</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E6%A8%A1%E5%9D%97%E7%AE%A1%E7%90%86"><span class="toc-number">1.3.</span> <span class="toc-text">3.模块管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B7%E4%BD%93%E5%86%99%E6%B3%95-2"><span class="toc-number">1.3.1.</span> <span class="toc-text">具体写法</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E6%89%93%E5%8C%85%E7%9A%84%E6%96%B9%E5%BC%8F"><span class="toc-number">1.4.</span> <span class="toc-text">4.打包的方式</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B7%E4%BD%93%E5%86%99%E6%B3%95-3"><span class="toc-number">1.4.1.</span> <span class="toc-text">具体写法</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AD%90%E5%B7%A5%E7%A8%8B%EF%BC%88%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AE%EF%BC%89"><span class="toc-number">2.</span> <span class="toc-text">子工程（基本配置）</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%9F%A5%E8%AF%86%E4%B8%80%EF%BC%9A%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C"><span class="toc-number">2.1.</span> <span class="toc-text">知识一：基本操作</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%9F%A5%E8%AF%86%E4%BA%8C%EF%BC%9A%E8%A1%A5%E5%85%85%E5%86%85%E5%AE%B9%EF%BC%9A%E5%86%85%E5%B5%8CWeb%E5%AE%B9%E5%99%A8-%E9%BB%98%E8%AE%A4Tomcat"><span class="toc-number">2.2.</span> <span class="toc-text">知识二：补充内容：内嵌Web容器(默认Tomcat)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B7%E6%9C%893%E4%B8%AA%E7%B1%BB%E5%9E%8B%E7%9A%84%E5%86%85%E5%B5%8CWeb%E5%AE%B9%E5%99%A8"><span class="toc-number">2.2.1.</span> <span class="toc-text">具有3个类型的内嵌Web容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tomcat%E8%AE%B2%E8%A7%A3"><span class="toc-number">2.2.2.</span> <span class="toc-text">tomcat讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9B%B4%E6%8D%A2%E5%86%85%E5%B5%8CWeb%E5%AE%B9%E5%99%A8"><span class="toc-number">2.2.3.</span> <span class="toc-text">更换内嵌Web容器</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%BF%85%E5%A4%87%E9%85%8D%E7%BD%AE"><span class="toc-number">3.</span> <span class="toc-text">必备配置</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B4%E5%90%88lombok"><span class="toc-number">3.1.</span> <span class="toc-text">整合lombok</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BD%95%E4%B8%BAlombok%EF%BC%9F"><span class="toc-number">3.1.1.</span> <span class="toc-text">何为lombok？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B7%E4%BD%93%E8%AE%B2%E8%A7%A3-1"><span class="toc-number">3.1.2.</span> <span class="toc-text">具体讲解</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#lombok%E9%85%8D%E7%BD%AE%EF%BC%88%E5%AD%90%E5%B7%A5%E7%A8%8B%EF%BC%89"><span class="toc-number">3.2.</span> <span class="toc-text">lombok配置（子工程）</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%90%8E%E7%AB%AF-lt-gt-%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-number">4.</span> <span class="toc-text">后端&lt;&#x3D;&#x3D;&#x3D;&gt;数据库</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81-lt-%E6%95%B4%E5%90%88Mysql-gt"><span class="toc-number">4.1.</span> <span class="toc-text">1、&lt;整合Mysql&gt;</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Mysql%E9%85%8D%E7%BD%AE%EF%BC%88%E8%99%9A%E6%8B%9F%E6%9C%BA%EF%BC%89"><span class="toc-number">4.1.1.</span> <span class="toc-text">Mysql配置（虚拟机）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Mysql%E9%85%8D%E7%BD%AE%EF%BC%88windows%EF%BC%89"><span class="toc-number">4.1.2.</span> <span class="toc-text">Mysql配置（windows）</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E7%89%88%E6%9C%AC%E5%8F%B7"><span class="toc-number">4.1.2.1.</span> <span class="toc-text">1.版本号</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E4%BE%9D%E8%B5%96"><span class="toc-number">4.1.2.2.</span> <span class="toc-text">2.依赖</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#2-1%E7%88%B6%E5%B7%A5%E7%A8%8B"><span class="toc-number">4.1.2.2.1.</span> <span class="toc-text">2.1父工程</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-2%E5%AD%90%E5%B7%A5%E7%A8%8B"><span class="toc-number">4.1.2.2.2.</span> <span class="toc-text">2.2子工程</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-yml%E9%85%8D%E7%BD%AE"><span class="toc-number">4.1.2.3.</span> <span class="toc-text">3.yml配置</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E8%A7%A3%E9%87%8A"><span class="toc-number">4.1.2.3.1.</span> <span class="toc-text">解释</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-lt-%E6%95%B4%E5%90%88Mybatis-Plus-gt"><span class="toc-number">4.2.</span> <span class="toc-text">2.&lt;整合Mybatis Plus&gt;</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1%E3%80%81%E4%BD%95%E4%B8%BAMybatis-Plus%EF%BC%9F"><span class="toc-number">4.2.1.</span> <span class="toc-text">2.1、何为Mybatis Plus？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2%E3%80%81Mybatis-Plus%E9%85%8D%E7%BD%AE"><span class="toc-number">4.2.2.</span> <span class="toc-text">2.2、Mybatis Plus配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-1%E7%89%88%E6%9C%AC%E5%8F%B7"><span class="toc-number">4.2.2.1.</span> <span class="toc-text">2.2.1版本号</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-2%E4%BE%9D%E8%B5%96"><span class="toc-number">4.2.2.2.</span> <span class="toc-text">2.2.2依赖</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#2-2-2-1%E7%88%B6%E5%B7%A5%E7%A8%8B"><span class="toc-number">4.2.2.2.1.</span> <span class="toc-text">2.2.2.1父工程</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-2-2-1%E5%AD%90%E5%B7%A5%E7%A8%8B"><span class="toc-number">4.2.2.2.2.</span> <span class="toc-text">2.2.2.1子工程</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-3yml%E9%85%8D%E7%BD%AE"><span class="toc-number">4.2.2.3.</span> <span class="toc-text">2.2.3yml配置</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E8%A7%A3%E9%87%8A-1"><span class="toc-number">4.2.2.3.1.</span> <span class="toc-text">解释</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3%E3%80%81Mybatis-Plus%E4%B8%AD%E7%9A%84%E6%B3%A8%E8%A7%A3-entity%E5%B1%82"><span class="toc-number">4.2.3.</span> <span class="toc-text">2.3、Mybatis Plus中的注解(entity层)</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-lt-%E6%95%B4%E5%90%88Druid-gt"><span class="toc-number">4.3.</span> <span class="toc-text">3.&lt;整合Druid&gt;</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#3-1%E3%80%81%E4%BD%95%E4%B8%BADruid%EF%BC%9F"><span class="toc-number">4.3.1.</span> <span class="toc-text">3.1、何为Druid？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-2%E3%80%81Druid%E9%85%8D%E7%BD%AE"><span class="toc-number">4.3.2.</span> <span class="toc-text">3.2、Druid配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-1%E7%89%88%E6%9C%AC%E5%8F%B7"><span class="toc-number">4.3.2.1.</span> <span class="toc-text">3.2.1版本号</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-2%E4%BE%9D%E8%B5%96"><span class="toc-number">4.3.2.2.</span> <span class="toc-text">3.2.2依赖</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#3-2-2-1%E7%88%B6%E5%B7%A5%E7%A8%8B"><span class="toc-number">4.3.2.2.1.</span> <span class="toc-text">3.2.2.1父工程</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3-2-2-2%E5%AD%90%E5%B7%A5%E7%A8%8B"><span class="toc-number">4.3.2.2.2.</span> <span class="toc-text">3.2.2.2子工程</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-3yml%E9%85%8D%E7%BD%AE-%E6%97%A0%E9%9C%80mysql%E7%9A%84yml%E9%85%8D%E7%BD%AE"><span class="toc-number">4.3.2.3.</span> <span class="toc-text">3.2.3yml配置(无需mysql的yml配置)</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-3%E3%80%81Druid%E6%95%B0%E6%8D%AE%E6%BA%90%E9%85%8D%E7%BD%AE"><span class="toc-number">4.3.3.</span> <span class="toc-text">3.3、Druid数据源配置</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E6%95%B4%E5%90%88Redis-%E2%80%94%E5%9C%A8%E8%99%9A%E6%8B%9F%E6%9C%BA%E5%BD%93%E4%B8%AD"><span class="toc-number">4.4.</span> <span class="toc-text">4.((整合Redis))—在虚拟机当中</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#4-1%E3%80%81%E4%BD%95%E4%B8%BARedis%EF%BC%9F"><span class="toc-number">4.4.1.</span> <span class="toc-text">4.1、何为Redis？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-2%E3%80%81Redis%E9%85%8D%E7%BD%AE"><span class="toc-number">4.4.2.</span> <span class="toc-text">4.2、Redis配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%89%88%E6%9C%AC%E5%8F%B7"><span class="toc-number">4.4.2.1.</span> <span class="toc-text">版本号</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BE%9D%E8%B5%96"><span class="toc-number">4.4.2.2.</span> <span class="toc-text">依赖</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#yml%E9%85%8D%E7%BD%AE"><span class="toc-number">4.4.2.3.</span> <span class="toc-text">yml配置</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3"><span class="toc-number">4.4.2.3.1.</span> <span class="toc-text">讲解</span></a></li></ol></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%89%8D%E7%AB%AF-lt-gt-%E5%90%8E%E7%AB%AF"><span class="toc-number">5.</span> <span class="toc-text">前端&lt;&#x3D;&#x3D;&#x3D;&gt;后端</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E6%95%B4%E5%90%88validation"><span class="toc-number">5.1.</span> <span class="toc-text">1.整合validation</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1%E3%80%81%E4%BD%95%E4%B8%BAvalidation%EF%BC%9F"><span class="toc-number">5.1.1.</span> <span class="toc-text">1.1、何为validation？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2%E3%80%81validation%E9%85%8D%E7%BD%AE"><span class="toc-number">5.1.2.</span> <span class="toc-text">1.2、validation配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-1%EF%BC%9A%E4%BE%9D%E8%B5%96"><span class="toc-number">5.1.2.1.</span> <span class="toc-text">1.2.1：依赖</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-2%EF%BC%9A%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F"><span class="toc-number">5.1.2.2.</span> <span class="toc-text">1.2.2：使用方式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-3%EF%BC%9Avalidation%E6%B3%A8%E8%A7%A3%E8%A1%A8"><span class="toc-number">5.1.2.3.</span> <span class="toc-text">1.2.3：validation注解表</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-4%EF%BC%9A%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%E5%99%A8GlobalExceptionHandler"><span class="toc-number">5.1.2.4.</span> <span class="toc-text">1.2.4：异常处理器GlobalExceptionHandler</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E6%95%B4%E5%90%88JWT-ThreadLocal"><span class="toc-number">5.2.</span> <span class="toc-text">2.整合JWT+ThreadLocal</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1%EF%BC%9A%E4%BD%95%E4%B8%BAJWT%EF%BC%9F"><span class="toc-number">5.2.1.</span> <span class="toc-text">2.1：何为JWT？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2%EF%BC%9AJWT%E7%BB%84%E6%88%90%E9%83%A8%E5%88%86%E8%AE%B2%E8%A7%A3"><span class="toc-number">5.2.2.</span> <span class="toc-text">2.2：JWT组成部分讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3%EF%BC%9AThreadLocal%E7%9A%84%E8%AE%B2%E8%A7%A3"><span class="toc-number">5.2.3.</span> <span class="toc-text">2.3：ThreadLocal的讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-4%EF%BC%9AJWT-ThreadLocal%E9%85%8D%E7%BD%AE"><span class="toc-number">5.2.4.</span> <span class="toc-text">2.4：JWT+ThreadLocal配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%89%88%E6%9C%AC%E5%8F%B7-1"><span class="toc-number">5.2.4.1.</span> <span class="toc-text">版本号</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BE%9D%E8%B5%96-1"><span class="toc-number">5.2.4.2.</span> <span class="toc-text">依赖</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%85%B7%E4%BD%93%E9%85%8D%E7%BD%AE%E9%A1%B9"><span class="toc-number">5.2.4.3.</span> <span class="toc-text">具体配置项</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E6%95%B4%E5%90%88PageHelper"><span class="toc-number">5.3.</span> <span class="toc-text">3.整合PageHelper</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#3-1%EF%BC%9A%E4%BD%95%E4%B8%BAPageHelper%EF%BC%9F"><span class="toc-number">5.3.1.</span> <span class="toc-text">3.1：何为PageHelper？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-2%EF%BC%9APageHelper%E9%85%8D%E7%BD%AE"><span class="toc-number">5.3.2.</span> <span class="toc-text">3.2：PageHelper配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%89%88%E6%9C%AC%E5%8F%B7-2"><span class="toc-number">5.3.2.1.</span> <span class="toc-text">版本号</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BE%9D%E8%B5%96-2"><span class="toc-number">5.3.2.2.</span> <span class="toc-text">依赖</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E6%95%B4%E5%90%88hutool-all%EF%BC%88%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E4%B8%8B%E8%BD%BD%E4%B8%AD%E9%9C%80%E7%94%A8%E5%88%B0%EF%BC%89"><span class="toc-number">5.4.</span> <span class="toc-text">4.整合hutool-all（文件上传下载中需用到）</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#4-1%E3%80%81%E4%BD%95%E4%B8%BAhutool-all%EF%BC%9F"><span class="toc-number">5.4.1.</span> <span class="toc-text">4.1、何为hutool-all？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-2%E3%80%81hutool-all%E9%85%8D%E7%BD%AE"><span class="toc-number">5.4.2.</span> <span class="toc-text">4.2、hutool-all配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%89%88%E6%9C%AC%E5%8F%B7-3"><span class="toc-number">5.4.2.1.</span> <span class="toc-text">版本号</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BE%9D%E8%B5%96-3"><span class="toc-number">5.4.2.2.</span> <span class="toc-text">依赖</span></a></li></ol></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/lemon-world/posts/dc99e4b2.html" title="项目搭建之文件上传下载"><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%97%B4%E8%B0%8D%E8%BF%87%E5%AE%B6%E5%AE%B6.png" onerror="this.onerror=null;this.src='/lemon-world/img/404.jpg'" alt="项目搭建之文件上传下载"/></a><div class="content"><a class="title" href="/lemon-world/posts/dc99e4b2.html" title="项目搭建之文件上传下载">项目搭建之文件上传下载</a><time datetime="2024-04-19T16:00:00.000Z" title="发表于 2024-04-20 00:00:00">2024-04-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/lemon-world/posts/cca50181.html" title="项目搭建之Vue工程之路由"><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E5%A4%95%E9%98%B3%E4%B8%8B%E7%9A%84%E7%BA%A2%E8%B7%AF%E7%81%AF.png" onerror="this.onerror=null;this.src='/lemon-world/img/404.jpg'" alt="项目搭建之Vue工程之路由"/></a><div class="content"><a class="title" href="/lemon-world/posts/cca50181.html" title="项目搭建之Vue工程之路由">项目搭建之Vue工程之路由</a><time datetime="2024-04-11T16:00:00.000Z" title="发表于 2024-04-12 00:00:00">2024-04-12</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/lemon-world/posts/1e302926.html" title="项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战"><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E8%BF%BD%E6%9C%88.png" onerror="this.onerror=null;this.src='/lemon-world/img/404.jpg'" alt="项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战"/></a><div class="content"><a class="title" href="/lemon-world/posts/1e302926.html" title="项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战">项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战</a><time datetime="2024-04-10T16:00:00.000Z" title="发表于 2024-04-11 00:00:00">2024-04-11</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/lemon-world/posts/7f721cb1.html" title="项目搭建之SpringBoot基本操作归纳"><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E6%A1%A5%E4%B8%8B%E5%A4%95%E9%98%B3.png" onerror="this.onerror=null;this.src='/lemon-world/img/404.jpg'" alt="项目搭建之SpringBoot基本操作归纳"/></a><div class="content"><a class="title" href="/lemon-world/posts/7f721cb1.html" title="项目搭建之SpringBoot基本操作归纳">项目搭建之SpringBoot基本操作归纳</a><time datetime="2024-03-26T16:00:00.000Z" title="发表于 2024-03-27 00:00:00">2024-03-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/lemon-world/posts/452204e8.html" title="项目搭建之SpringBoot配置归纳"><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AD%94%E6%B3%95%E5%B0%91%E5%A5%B3%E5%B0%8F%E5%9C%86.png" onerror="this.onerror=null;this.src='/lemon-world/img/404.jpg'" alt="项目搭建之SpringBoot配置归纳"/></a><div class="content"><a class="title" href="/lemon-world/posts/452204e8.html" title="项目搭建之SpringBoot配置归纳">项目搭建之SpringBoot配置归纳</a><time datetime="2024-03-17T16:00:00.000Z" title="发表于 2024-03-18 00:00:00">2024-03-18</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AD%94%E6%B3%95%E5%B0%91%E5%A5%B3%E5%B0%8F%E5%9C%86.png')"><div id="footer-wrap"><div class="copyright">&copy;2023 - 2024 By 袖清暮雨</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">welcome to <a href="https://lemonworld.gitee.io/lemon-world/">袖清暮雨</a> Blog!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/lemon-world/js/utils.js"></script><script src="/lemon-world/js/main.js"></script><script src="/lemon-world/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><div class="js-pjax"><script>(() => {
  const initValine = () => {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 'lmEQpOsJf8mT3BIGHZZ7EDq4-gzGzoHsz',
      appKey: '7APMLg7dJeJb0sE6hHymEyaY',
      avatar: 'monsterid',
      serverURLs: '7frkCVvvwQAZBPCcjmeKotvz',
      emojiMaps: "",
      path: window.location.pathname,
      visitor: true
    }, null))
  }

  const loadValine = async () => {
    if (typeof Valine === 'function') initValine()
    else {
      await getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js')
      initValine()
    }
  }

  if ('Valine' === 'Valine' || !false) {
    if (false) btf.loadComment(document.getElementById('vcomment'),loadValine)
    else setTimeout(loadValine, 0)
  } else {
    window.loadOtherComment = loadValine
  }
})()</script></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/metingjs/dist/Meting.min.js"></script><div class="app-refresh" id="app-refresh" style="position: fixed;top: -2.2rem;left: 0;right: 0;z-index: 99999;padding: 0 1rem;font-size: 15px;height: 2.2rem;transition: all 0.3s ease;"><div class="app-refresh-wrap" style=" display: flex;color: #fff;height: 100%;align-items: center;justify-content: center;"><label>✨ 有新文章啦！✨  👉</label><a href="javascript:void(0)" onclick="location.reload()"><span style="color: #fff;text-decoration: underline;cursor: pointer;">点击使用</span></a></div></div><script>if ('serviceWorker' in navigator) {
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.addEventListener('controllerchange', function() {
showNotification()
})
}
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js')
})
}
function showNotification() {
if (GLOBAL_CONFIG.Snackbar) {
var snackbarBg =
document.documentElement.getAttribute('data-theme') === 'light' ?
GLOBAL_CONFIG.Snackbar.bgLight :
GLOBAL_CONFIG.Snackbar.bgDark
var snackbarPos = GLOBAL_CONFIG.Snackbar.position
Snackbar.show({
text: '✨ 有新文章啦！✨  👉',
backgroundColor: snackbarBg,
duration: 500000,
pos: snackbarPos,
actionText: '点击使用',
actionTextColor: '#fff',
onActionClick: function(e) {
location.reload()
},
})
} else {
var showBg =
document.documentElement.getAttribute('data-theme') === 'light' ?
'#3b70fc' :
'#1f1f1f'
var cssText = `top: 0; background: ${showBg};`
document.getElementById('app-refresh').style.cssText = cssText
}
}</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/lemon-world/js/search/local-search.js"></script></div></div><!-- hexo injector body_end start --><script data-pjax>
  function butterfly_clock_anzhiyu_injector_config(){
    var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
    var item_html = '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img class="entered loading" id="card-clock-loading" src= "" data-lazy-src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu@1.1.6/lib/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading"/></div></div></div></div></div>';
    console.log('已挂载butterfly_clock_anzhiyu')
    if(parent_div_git) {
      parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var qweather_key = '8fb12d98d85c4c88831aa57a850d7b9f';
  var gaud_map_key = '70fbf493bf0d0ba744a308b047ea559e';
  var baidu_ak_key = 'undefined';
  var flag = 0;
  var clock_rectangle = '112.6534116,27.96920845';
  var clock_default_rectangle_enable = 'true';

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_clock_anzhiyu_injector_config();
  }
  else if (epage === cpage){
    butterfly_clock_anzhiyu_injector_config();
  }
  </script><script src="https://widget.qweather.net/simple/static/js/he-simple-common.js?v=2.0"></script><script data-pjax src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu@1.1.6/lib/clock.min.js"></script><div class="js-pjax"><script async="async">var arr = document.getElementsByClassName('recent-post-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '1.5s');
    arr[i].setAttribute('data-wow-delay', '200ms');
    arr[i].setAttribute('data-wow-offset', '30');
    arr[i].setAttribute('data-wow-iteration', '1');
  }</script><script async="async">var arr = document.getElementsByClassName('card-widget');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '');
    arr[i].setAttribute('data-wow-delay', '200ms');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('flink-list-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__flipInY');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('flink-list-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__animated');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('article-sort-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__slideInRight');
    arr[i].setAttribute('data-wow-duration', '1.5s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('site-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__flipInY');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('site-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__animated');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script></div><script defer src="https://cdn.cbd.int/hexo-butterfly-wowjs/lib/wow.min.js"></script><script defer src="https://cdn.cbd.int/hexo-butterfly-wowjs/lib/wow_init.js"></script><!-- hexo injector body_end end --><script src="/lemon-world/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"tagMode":false,"debug":false,"model":{"jsonPath":"/lemon-world/live2dw/assets/koharu.model.json"},"display":{"position":"left","width":150,"height":300},"mobile":{"show":false},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/"});</script></body></html>